//
//  AudioListControllerT.m
//  AVAudioPlayerDemo
//
//  Created by 周文成 on 2018/1/3.
//  Copyright © 2018年 C-LOVE. All rights reserved.
//

#import "AudioListController.h"
#import "MusicPath.h"
#import "PlayerController.h"

@interface AudioListController () {
    NSArray *_musicPaths;
}




@end

@implementation AudioListController

- (void)viewDidLoad {
    [super viewDidLoad];
    _musicPaths =[MusicPath musicPaths];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _musicPaths.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *identifier = @"AudioListController";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if(!cell){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault     reuseIdentifier:identifier];
    }
    NSString *path = [_musicPaths objectAtIndex:indexPath.row];
    cell.textLabel.text = [MusicPath musicNameWithPath:path];
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    PlayerController *controller = [PlayerController sharedInstance];
    controller.musicPaths = _musicPaths;
    controller.selectedIndex = indexPath.row;
    [self.navigationController pushViewController:controller animated:YES];
} 







@end
